package com.songsf.learn.rest;

import com.songsf.learn.Book;
import com.songsf.learn.service.BookCache;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by songsf on 2017/11/12.
 */

@RequestMapping(value = "/api/v1.0")
@RestController
public class CacheTestController {
    @Autowired
    private BookCache bookCache;

    @RequestMapping(value = "/cache/test",method = RequestMethod.GET)
    @ApiOperation(value = "缓存测试",notes = "")
    public Book getBook(@RequestParam()String bookName){
        return bookCache.getBook(bookName);
    }

    @RequestMapping(value = "/cache/names",method = RequestMethod.GET)
    @ApiOperation(value = "缓存测试",notes = "")
    public String getNames(@RequestParam()String name){
        return bookCache.getName(name);
    }

}
